﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Aliyeye.Car.Net.Utility
{
    public static class ControlExtensions
    {
        /// <summary>
        /// Gets if the control is in design mode, or if any of its
        /// parents are in design mode.
        /// </summary>
        public static bool IsDesignerHosted(this Control owner)
        {
            Control ctrl = owner;
            while (ctrl != null)
            {
                if (ctrl.Site == null)
                    return false;
                if (ctrl.Site.DesignMode == true)
                    return true;
                ctrl = ctrl.Parent;
            }
            return false;
        }
    }
}
